num=1400
def intToRoman(num):
    #定义一个字典
    dictionary={1:'I',5:'V',10:'X',50:'L',100:'C',500:'D',1000:'M'}
    p=num
    s=""
    while p>0:
        if p>=1000:
            p-=1000
            s+="M"
        elif p<1000 and p>=900:
            p-=900
            s+="CM"
        elif p<900 and p>=500:
            p-=500
            s+=dictionary[500]
        elif p<500 and p>=400:
            p-=400
            s+=dictionary[100]+dictionary[500]
        elif p<400 and p>=100:
            p-=100
            s+=dictionary[100]
        elif p<100 and p>=90:
            p-=90
            s+=dictionary[10]+dictionary[100]
        elif p<90 and p>=50:
            p-=50
            s+=dictionary[50]
        elif p<50 and p>=40:
            p-=40
            s+=dictionary[10]+dictionary[50]
        elif p<40 and p>=10:
            p-=10
            s+=dictionary[10]
        elif p<10 and p>=9:
            p-=9
            s+=dictionary[1]+dictionary[10]
        elif p<9 and p>=5:
            p-=5
            s+=dictionary[5]
        elif p==4:
            p-=4
            s+=dictionary[1]+dictionary[5]
        else:
            p-=1
            s+=dictionary[1]
    print(s)

intToRoman(num)

